#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>

#include "xx.h"
#include "torrent.h"
#include "tools.h"
//#include "interface.h"

BOOL g_exit = FALSE;

int g_debug = 3;

int main(int argc, char **argv)
{
	xx_torrent		torrent = {{0}};

	xx_dbg("argc: %d\n", argc);

	if ( (argc != 2) || (-1 == check_torrent_name(argv[1]))) {
		xx_inf("Useage:\n\t./xx .torrent, ");
		return -1;
	}

	/* signal handle */
	signal(SIGPIPE, SIG_IGN);
//	signal(SIGINT, control_interface);

	/* .torret parse */
	if ( xx_torrent_init(argv[1], &torrent) < 0 ) {
		return -1;
	}

	/* start */
	xx_torrent_start(&torrent);

	/* main while */
	while ( !g_exit ) {
		sleep(1);
	}

	/* exit */

	return 0;
}


